let OSS = require('ali-oss');
export let client = new OSS({
  region: 'oss-cn-hangzhou',
  accessKeyId: 'LTAI4G7r5uvuxTLQ6NkfeTi7',
  // accessKeyId: 'LTAI4G3B9GzBxd9JaehF8vZT',
  accessKeySecret: 'dX7LOwFfxw0nXNNvsjKtKmVrJSS3j4',
  // accessKeySecret: 'rwIn5Y4DRZE16ir36GtcskZC57ECtQ',
  bucket: 'hhx-files'
});

export const upload = (fileName, file, cb) => {
  client.put("web/" + fileName, file).then((result) => {
    cb(true, result);
  }).catch(function (err) {
    cb(false, "上传附件失败");
  });
}

export const multiUpload = (fileName, file, cb, p) => {
  client.multipartUpload("web/" + fileName, file, p).then((result) => {
    cb(true, result);
  }).catch(function (err) {
    cb(false, "上传附件失败");
  });
}
